<?php
class special_recommendModel extends baseModel{
    protected $table = 'special_recommend';

    //保存推荐位关联
    public function special_save($str=null,$id) {
        if(empty($str)){
            return false;
        }
        $this->special_del($id);
        $str=explode(',', $str);
        foreach ($str as $value) {
            $data['pid']=$value;
            $data['id']=$id;
            $this->insert($data);
        }
    }

    //通过推荐位内容关联
    public function relation_del($pid) {
        return $this->delete('pid='.$pid);
    }

    //删除内容推荐关联
    public function special_del($id) {
        return $this->delete('id='.$id);
    }

    //获取推荐位数组
    public function relation_array($id){
        $list=$this->select('id='.$id);
        if(empty($list)){
            return false;
        }
        foreach ($list as $value) {
            $recommend[]=$value['pid'];
        }
        return $recommend;
    }
	
}